<template>
  <div
    class="model-switch-container"
    :style="{
      backgroundColor: themeStyle[theme].backgroundColor1,
      color: themeStyle[theme].textColor3
    }"
  >
    <div
      class="item-icon"
      :class="canvasMode.current === 'select' ? 'item-icon-active' : ''"
      @click="switchCanvasModel('select')"
    >
      <svg-icon
        name="canvasCursor"
        size="1.2em"
        :color="canvasMode.current === 'select' ? '#0087dc99' : '#888'"
      ></svg-icon>
    </div>
    <div
      class="item-icon"
      :class="canvasMode.current === 'drag' ? 'item-icon-active' : ''"
      @click="switchCanvasModel('drag')"
    >
      <svg-icon
        name="canvasHand"
        size="1.2em"
        :color="canvasMode.current === 'drag' ? '#0087dc99' : '#888'"
      ></svg-icon>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useStyleStore } from '@renderer/store/globalStyle/style'
import { storeToRefs } from 'pinia'
import { useCanvasParameterStore } from '@renderer/store/canvas/canvasParameter'
import { changeCanvasMode } from '@renderer/store/canvas/otherFun'

const canvasParameterStore = useCanvasParameterStore()
const { canvasMode } = storeToRefs(canvasParameterStore)

const styleStore = useStyleStore()
const { theme, themeStyle } = storeToRefs(styleStore)

const switchCanvasModel = (mode: 'select' | 'drag') => {
  canvasMode.value.before = canvasMode.value.current
  console.log(canvasMode.value.before)
  changeCanvasMode(mode)
}
</script>

<style scoped lang="scss">
.model-switch-container {
  width: 100%;
  height: 100%;
  box-shadow: 0px 0px 10px #0000001a;
  border-radius: 5px;
  display: flex;
  justify-content: center;
  gap: 15px;
  align-items: center;

  .item-icon {
    width: 25px;
    height: 25px;
    border-radius: 5px;
    &:hover {
      background-color: #00000011;
    }
  }
  .item-icon-active {
    background-color: $icon-active-bgColor;
  }
}
</style>
